Type RateCounter

	Field counter:Int  = 0
	Field interval:Int = 1000
	Field rate:Int     = 0
	Field timeout:Int  = 0
	
	Method SetInterval(i:Int)
		counter   = 0
		interval  = i
		rate      = 0
		timeout   = MilliSecs() + interval
	End Method
	
	Method Update()
		Local m:Int = MilliSecs()
		If m >= timeout Then
			rate    = counter
			counter = 0
			timeout = m + interval 
		End If
	End Method
	
	Method Count()
		Update()
		counter:+1
	End Method
	
	Method GetRate:Int()
		Update()
		Return rate
	End Method

End Type
